//
//  ViewController.m
//  EXKVO
//
//  Created by Jiafan on 12/11/15.
//  Copyright © 2015 加帆. All rights reserved.
//

#import "ViewController.h"
#import "SomeWidget.h"
@interface ViewController ()

@property (weak, nonatomic) IBOutlet SomeWidget *headIV;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //*
    [self.headIV addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
     /*/
    [_headIV addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
    //*/
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if([keyPath isEqualToString:@"frame"]){
        CGRect frame = [(UIView *)object frame];
        NSLog(@"frame:%@",NSStringFromCGRect(frame));
    }
}
- (IBAction)changeFrame:(id)sender
{
    CGRect frame = self.headIV.frame;
    frame.size.width += 20;
    self.headIV.frame = frame;
}
@end
